//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for MediaStore
public struct MediaStoreErrorType: AWSErrorType {
    enum Code: String {
        case containerInUseException = "ContainerInUseException"
        case containerNotFoundException = "ContainerNotFoundException"
        case corsPolicyNotFoundException = "CorsPolicyNotFoundException"
        case internalServerError = "InternalServerError"
        case limitExceededException = "LimitExceededException"
        case policyNotFoundException = "PolicyNotFoundException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize MediaStore
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The container that you specified in the request already exists or is being updated.
    public static var containerInUseException: Self { .init(.containerInUseException) }
    /// The container that you specified in the request does not exist.
    public static var containerNotFoundException: Self { .init(.containerNotFoundException) }
    /// The CORS policy that you specified in the request does not exist.
    public static var corsPolicyNotFoundException: Self { .init(.corsPolicyNotFoundException) }
    /// The service is temporarily unavailable.
    public static var internalServerError: Self { .init(.internalServerError) }
    /// A service limit has been exceeded.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// The policy that you specified in the request does not exist.
    public static var policyNotFoundException: Self { .init(.policyNotFoundException) }
}

extension MediaStoreErrorType: Equatable {
    public static func == (lhs: MediaStoreErrorType, rhs: MediaStoreErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension MediaStoreErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
